/*  1:   */ package org.intellij.lang.regexp.psi.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.search.PsiElementProcessor.FindFilteredElement;
import com.intellij.psi.util.PsiElementFilter;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import org.intellij.lang.regexp.psi.RegExpBackref;
import org.intellij.lang.regexp.psi.RegExpElementVisitor;
import org.intellij.lang.regexp.psi.RegExpGroup;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */ 
/* 18:   */ public class RegExpBackrefImpl
/* 19:   */   extends RegExpElementImpl
/* 20:   */   implements RegExpBackref
/* 21:   */ {
/* 22:   */   public RegExpBackrefImpl(ASTNode paramASTNode)
/* 23:   */   {
/* 24:37 */     super(paramASTNode);
/* 25:   */   }
/* 26:   */   
/* 27:   */   public int getIndex()
/* 28:   */   {
/* 29:41 */     String str = getUnescapedText();
/* 30:42 */     assert (str.charAt(0) == '\\');
/* 31:43 */     return Integer.parseInt(str.substring(1));
/* 32:   */   }
/* 33:   */   
/* 34:   */   public void accept(RegExpElementVisitor paramRegExpElementVisitor)
/* 35:   */   {
/* 36:47 */     paramRegExpElementVisitor.visitRegExpBackref(this);
/* 37:   */   }
/* 38:   */   
/* 39:   */   public RegExpGroup resolve()
/* 40:   */   {
/* 41:51 */     final int i = getIndex();
/* 42:   */     
/* 43:53 */     PsiElementProcessor.FindFilteredElement localFindFilteredElement = new PsiElementProcessor.FindFilteredElement(new PsiElementFilter()
/* 44:   */     {
/* 45:   */       int groupCount;
/* 46:   */       
/* 47:   */       public boolean isAccepted(PsiElement paramAnonymousPsiElement)
/* 48:   */       {
/* 49:57 */         if (((paramAnonymousPsiElement instanceof RegExpGroup)) && 
/* 50:58 */           (((RegExpGroup)paramAnonymousPsiElement).isCapturing()) && (++this.groupCount == i)) {
/* 51:59 */           return true;
/* 52:   */         }
/* 53:62 */         return paramAnonymousPsiElement == RegExpBackrefImpl.this;
/* 54:   */       }
/* 55:65 */     });
/* 56:66 */     PsiTreeUtil.processElements(getContainingFile(), localFindFilteredElement);
/* 57:67 */     if ((localFindFilteredElement.getFoundElement() instanceof RegExpGroup)) {
/* 58:68 */       return (RegExpGroup)localFindFilteredElement.getFoundElement();
/* 59:   */     }
/* 60:70 */     return null;
/* 61:   */   }
/* 62:   */   
/* 63:   */   public PsiReference getReference()
/* 64:   */   {
/* 65:74 */     new PsiReference()
/* 66:   */     {
/* 67:   */       public PsiElement getElement()
/* 68:   */       {
/* 69:76 */         return RegExpBackrefImpl.this;
/* 70:   */       }
/* 71:   */       
/* 72:   */       public TextRange getRangeInElement()
/* 73:   */       {
/* 74:80 */         return TextRange.from(0, getElement().getTextLength());
/* 75:   */       }
/* 76:   */       
/* 77:   */       @NotNull
/* 78:   */       public String getCanonicalText()
/* 79:   */       {
/* 80:85 */         String tmp9_4 = getElement().getText();
/* 81:85 */         if (tmp9_4 == null) {
/* 82:85 */           throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl$2", "getCanonicalText" }));
/* 83:   */         }
/* 84:85 */         return tmp9_4;
/* 85:   */       }
/* 86:   */       
/* 87:   */       public PsiElement handleElementRename(String paramAnonymousString)
/* 88:   */         throws IncorrectOperationException
/* 89:   */       {
/* 90:89 */         throw new IncorrectOperationException();
/* 91:   */       }
/* 92:   */       
/* 93:   */       public PsiElement bindToElement(@NotNull PsiElement paramAnonymousPsiElement)
/* 94:   */         throws IncorrectOperationException
/* 95:   */       {
/* 96:93 */         if (paramAnonymousPsiElement == null) {
/* 97:93 */           throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl$2", "bindToElement" }));
/* 98:   */         }
/* 99:93 */         throw new IncorrectOperationException();
/* :0:   */       }
/* :1:   */       
/* :2:   */       public boolean isReferenceTo(PsiElement paramAnonymousPsiElement)
/* :3:   */       {
/* :4:97 */         return Comparing.equal(paramAnonymousPsiElement, resolve());
/* :5:   */       }
/* :6:   */       
/* :7:   */       public boolean isSoft()
/* :8:   */       {
/* :9::1 */         return false;
/* ;0:   */       }
/* ;1:   */       
/* ;2:   */       public PsiElement resolve()
/* ;3:   */       {
/* ;4::5 */         return RegExpBackrefImpl.this.resolve();
/* ;5:   */       }
/* ;6:   */       
/* ;7:   */       @NotNull
/* ;8:   */       public Object[] getVariants()
/* ;9:   */       {
/* <0:;0 */         Object[] tmp3_0 = ArrayUtil.EMPTY_OBJECT_ARRAY;
/* <1:;0 */         if (tmp3_0 == null) {
/* <2:;0 */           throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl$2", "getVariants" }));
/* <3:   */         }
/* <4:;0 */         return tmp3_0;
/* <5:   */       }
/* <6:   */     };
/* <7:   */   }
/* <8:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.psi.impl.RegExpBackrefImpl

 * JD-Core Version:    0.7.0.1

 */